package Primary;

class MyThread3 implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("run loop");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class ThreadDemo2 {
    public static void main1(String[] args) {
        Runnable runnable = new MyThread3();
        Thread t = new Thread(runnable);
        t.start();
        while (true) {
            System.out.println("main loop");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args) {
        Thread t = new Thread (new MyThread3());
        t.start();
        while (true) {
            System.out.println("main loop");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
